﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Ones.Dal.Repository.Interfaces
{
    public interface IDao<T> where T : class
    {
        /// <summary>
        /// Insert new record into database table.
        /// </summary>
        /// <param name="t">ORM type</param>
        /// <returns><b>true</b> if operation success.</returns>
        bool create(T t);

        /// <summary>
        /// Update record in database table.
        /// </summary>
        /// <param name="t">ORM type</param>
        /// <returns><b>true</b> if operation success.</returns>
        bool update(T t);

        /// <summary>
        /// Delete record in database table.
        /// </summary>
        /// <param name="t">ORM type</param>
        /// <returns><b>true</b> if operation success.</returns>
        bool delete(Object id);

        /// <summary>
        /// Query to database table, select all records.
        /// </summary>
        /// <returns><b>null</b> if table has no any record.</returns>
        List<T> getAll();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T getById(Object id);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="whereCondition"></param>
        /// <returns></returns>
        List<T> getMultiple(Expression<Func<T, bool>> whereCondition);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="whereCondition"></param>
        /// <returns></returns>
        T getSingle(Expression<Func<T, bool>> whereCondition);
    }
}